/**************************************************************************
 * @doc EMV20
 * @module EMV20.c |  
 * Source file for creating 1.4 functions so EMV 1.4 will be compatable with 2.0
 *
 * Product     :   SoftPay 2000 (Global Payment Methodology).
 * <nl>Developer   :   
 * <nl>Notes       :
 *
 * @head3 EMV20 Functions |
 * @index | EMV20
 * @end
 *
 * Copyright (c) 1996-2001 by VeriFone Inc. All rights reserved.
 * 
 * No part of this software may be used, stored, compiled, reproduced,
 * modified, transcribed, translated, transmitted, or transferred, in any form 
 * or by any means whether electronic, mechanical, magnetic, optical, 
 * or otherwise, without the express prior written permission of VeriFone, Inc.
 *
 * Revision History
 * ------------------------------------------------------------------------
 $Log: /SoftPay/SPK2SIM/Source/projects/VITL/proj/EMV20.c $
 * 
 * 
********************************************************************************/
#include <project.h>

#ifdef EMV_MODULE
#include <define.h>
#include <transact.h>
#include "EMV20.h"
#include "cdt.h"
#include "tct.h"
#include "msg.h"
#include <emvfuncs.h>

int inGetCDTIssuerNum()
{
    return(inGetIssuerNum());
}

void vdSetCDTSignLine(VS_BOOL fSignLine)
{
    vdSetSignLine(fSignLine);
}

VS_BOOL fGetCDTExpDtReqd()
{
    return(fGetExpDtReqd());
}

int inGetTCTIdleTimeOut()
{
    return(inGetIdleTimeOut());
}

/********************************************************************************************* 
* @func int | inEMVPrepareBatchFlow | 
*       Transaction flow function to write all the relevant EMV stuff to the batch flexi
*       record. See EMV'96, Terminal Spec., III, Table III-9.
*
*       NB - this function just writes the minimum data required in batch according to the
*       EMV spec. Customer requirements may demand more EMV data be written to batch.
*
* @parm TRANSACTION_OBJECT *| pobTran 
*       Transaction object
*
* @rdesc return values.
* @flag int    |  VS_SUCCESS
* @end
**********************************************************************************************/

int inEMVPrepareBatchFlow(TRANSACTION_OBJECT *pobTran)
{
int  inRetVal=VS_SUCCESS;

	if (pobTran->inChipStatus == EMV_CARD)
	{
        inRetVal=inEMVPrepareBatch(pobTran);
    }
	return(inRetVal);
}



/********************************************************************************************* 
* @func int | inEMVCardholderVerificationEnvelope | 
*       Transaction flow function to perform Cardholder Verification for an EMV transaction.
*
* @parm TRANSACTION_OBJECT *| pobTran 
*       Transaction object
*
* @rdesc return values.
* @flag int    |  VS_ERR
* @flag int    |  VS_SUCCESS
* @end
**********************************************************************************************/

int inEMVCardholderVerificationEnvelope(TRANSACTION_OBJECT *pobTran)
{

	if (pobTran->inChipStatus == EMV_CARD)
	{

        if (inEMVCardholderVerification(pobTran) == VS_ERR)
            return (VS_ERR);
        vdSetOpenTabSLine(fGetSignLine());    
	}


    return(VS_SUCCESS);
}
// Use inEMVCardholderVerificationEnvelope and inEMVResetPCT in pairs since PCT is only read at init
int inEMVResetPCT(TRANSACTION_OBJECT *pobTran)
{
	if (pobTran->inChipStatus == EMV_CARD)
	{
        if (inLoadPCTRec(0) != VS_SUCCESS)
        {
            return (PCT_ERR_MSG);
        }
    }
}

#endif

